<h2>Working with Git</h2>

<p>Firstly, if this is your first time working with Git you may want to look into using something like <a href="http://www.syntevo.com/smartgit/index.html" target="_blank">SmartGit</a> to save yourself the trouble of working out the command line tool.</p>
<p>Next you need to pick your work-flow:</p>
<h3>Workflow #1: Creating a fork</h3>
<p>Go to out <a href="http://github.com/pyrocms/pyrocms/" target="_blank">GitHub Repository</a> and click "Fork".</p>
<p>You will be set up with a new repository which is a copy of ours. That means you can work on your copy of our repository without us needing to give you access to anything. You can use the following command to get a copy on your computer in your current directory. Best to put this into htdocs (or somewhere you have a server running).</p>
<pre><code>$ git clone git@github.com:yourusername/pyrocms.git</code></pre>
<p>If you are new to Git and GitHub then it is <em>very </em>important that you read the Getting Started section on <a href="http://help.github.com/" target="_blank">GitHub Help</a>.</p>
<p>Now you can edit away on the source code and everything is tracked. When you commit your work <em>please</em> commit carefully and do not send use your config.php or database.php files in the changes.</p>
<h3>Workflow #2: Using an external repository</h3>
<p>You can use your own Git repository if you <em>really</em> need to, but make sure you set up a read-only address for us to use. Then just email support@pyrocms.com your URL and a description of what you have actually done.</p>
<h3>Commiting your changes</h3>
<p>When stuff is done, find out what files are changed, add / remove the correct files and commit.</p>
<pre><code>  $ git status<br>  $ git add somefile<br>  $ git add somefolder/ <br>  $ git rm afile andanotherfile<br>  $ git rm -r wholefolder/<br>  $ git commit -m "bug: I fixed something</code></pre>
<p>When you have commited this, it doesn't actually go anywhere. You have to push your work for that to happen. This means you can “commit” lots of work, but only send it all off when you are ready. Means multiple commits to secure what you have done, but the rest of the world isn’t lumbered with incomplete work until you are ready!</p>
<pre><code>  $ git push origin master</code></pre>
<p>If that says “rejected” anywhere it is most likely that your copy is out of date. This will only happen if anyone else is working on your fork or external repo. Pull the latest copy, then try agian.</p>
<pre><code>  $ git pull origin master</code></pre>
<p>If you have anything to “revert” (meaning undo back to how it was before you edited it) then you can do this:</p>
<pre><code>  $ git checkout -- filepath/filename.php</code></pre>
<h3>Pulling PyroCMS updates</h3>
<p>Even if you have a copy of our repository then you are basically taking a snapshot of our repo as it is at the time. If we push new commits you will miss out entirely unless you add us as another remote (this works for either workflow).</p>
<pre><code>  $ git remote add pyrocms git://github.com/pyrocms/pyrocms.git<br>  $ git pull pyrocms master<br>  $ git push origin master</code></pre>
<p>That will take any new commits from the main PyroCMS repository and push them to your own repository.</p>
<p>If you start spotting any messages about "CRLF line endings bla bla bla", make sure you have your <a title="Set up Git to use correct line endings" href="http://help.github.com/dealing-with-lineendings/" target="_blank">line endiings set up correctly</a>. If you do not have your line endings set up right we'll ignore your commits as it will mark pretty much every file as changed and mask your actual changes.</p>
